<%@page contentType="text/html; charset=utf-8" %>
<%-- 
/**
 * 创建信息
 * ============= jsp名: /work/admin/xtgl/dict/dict_detail.jsp
 * 页面作用描述:  数据字典项的修改
 * 创建人：zhongjianjun
 * 创建时间： 2013-1-18 
 * 修改信息1=============
 * 修改类型: //1.修改bug 2.业务变化修改 
 * 修改描述: 
 * 修改人： zhongjianjun
 * 修改时间：2013-1-24
 */
 --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>智慧校园-后台管理系统</title>
		<%@ include file="/comm/jsp/public.jsp" %>
		<!--通用css-->
		<link rel="stylesheet" type="text/css" media="all" href="<%=path%>/work/comm/css/common.css" />
		<!--通用js-->
		<script type="text/javascript" src="<%=path%>/work/comm/js/public.js"></script>
		<!--表单验证css-->
		<link rel="stylesheet" href="<%=path%>/comm/plug/validateform/validationEngine.jquery.css" type="text/css"/>
		<!--表单验证js-->
		<script src="<%=path%>/comm/plug/validateform/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
		<script src="<%=path%>/comm/plug/validateform/jquery.validationEngine-zh_CN.js" type="text/javascript" charset="utf-8"></script>
		<style>
			body {min-width: 100px;}
		</style>
		<script type="text/javascript">
			//全局变量
			var dictSn = art.dialog.data("dict_sn"); //字典流水号		
			//初始化页面
			$(function(){
				if(dictSn!=null && dictSn!=''){
					ajaxOtherCall({
						 url : "<%=path%>/work/admin/xtgl/json/dict_opt_find.action", //访问页面 
						 data :{"dict.dict_sn":$.trim(dictSn)},
				         _callBackOK : loadDictCallBack
					});
					$("#dict_detail_li").html("<a href='<%=path%>/work/admin/xtgl/dict/dict_options.jsp'>"+$("#dict_detail_li").text()+"</a>");
				}
				//为表单注册验证
				$("#dictForm").validationEngine({
					ajaxFormValidation: true,
					ajaxFormValidationMethod: 'post',
					ajaxFormValidationURL:"<%=path%>/work/admin/xtgl/json/dict_opt_checkDictForm.action",
					onAjaxFormComplete: ajaxValidationCallback
		    	});
			});
			//ajax字段验证：验证字典编码的唯一性
            $.validationEngineLanguage.allRules["ajaxDictCodeCall"] = {
				"url": "<%=path%>/work/admin/xtgl/json/dict_opt_checkDictCode.action",
				"extraDataDynamic":["#dict\\.temp_dict_code"],
                "alertText": "* 此字典编码已存在",
                "alertTextLoad": "* 正在验证字典编码唯一性...",
                "alertTextOk": "* 此字典编码可用"
			};
			//ajax表单验证完成回调函数
            function ajaxValidationCallback(status, form, json, options){
				if(status === true) {
					saveDict();
				}
			}
			
			//查询字典项的回调函数
			function loadDictCallBack(data){
				var dict=data.dict;
               	$("#dict\\.dict_code").val(dict.dict_code);
                $("#dict\\.dict_name").val(dict.dict_name);
                $("#dict\\.dict_type").val(dict.dict_type);
                $("#dict\\.temp_dict_code").val(dict.dict_code);
                $("#dict\\.is_manager_opr").attr("checked", dict.is_manager_opr==1?true:false);
                chkbxStatu = $("#dict\\.is_manager_opr").attr("checked");
                art.dialog.data("dict_code",dict.dict_code);
			}
			
			//点击保存按钮
			function saveDict() {
				$("#save_btn").attr("disabled",true); 
				ajaxOtherCall({
					 url : "<%=path%>/work/admin/xtgl/json/dict_opt_save.action", //访问页面 
					 data :{"dict.dict_sn":$.trim(dictSn),
							"dict.dict_code":$.trim($("#dict\\.dict_code").val()),
							"dict.dict_name":$.trim($("#dict\\.dict_name").val()),
							"dict.temp_dict_code":$.trim($("#dict\\.dict_code").val()),
							"dict.dict_type":$.trim($("#dict\\.dict_type").val()),
							"dict.is_manager_opr":$("#dict\\.is_manager_opr").attr("checked")=="checked"?1:0
						    },
					 _beforeSendText:"正在保存中，请稍等...",//加载前默认提示
			         _callBackOK : saveDictCallBack
				});
			}
			//保存成功回调函数
			function saveDictCallBack(data){
				art.dialog.alert("保存成功！！！",true,"succeed");
				art.dialog.data("dict_sn",data.dict.dict_sn);
				art.dialog.data("dict_code",data.dict.dict_code);
				art.dialog.data("updated",true); //标识返回父页面时是否刷新
				dictSn = art.dialog.data("dict_sn"); //更新dict_sn的值
				$("#dict\\.dict_type").val(data.dict.dict_type);
                $("#dict\\.temp_dict_code").val(data.dict.dict_code);
				$("#dict_detail_li").html("<a href='<%=path%>/work/admin/xtgl/dict/dict_options.jsp'>"+$("#dict_detail_li").text()+"</a>");
				$("#save_btn").attr("disabled",false);
			}
	</script>
	</head>
	<body>
	<!--学校信息-->
		<div class="bz_div" style="width:650px; margin-top:10px"> 
			<div class="bz_tit" >
				<div style="margin-left:10px;" >数据字典编辑信息</div>
   		 	</div><!-- .bz_tit -->
			 <div class="section" style="margin-top:10px">
	  		  <ul class="tabs">
					<li class="current"><a href="<%=path%>/work/admin/xtgl/dict/dict_detail.jsp">数据字典</a></li>
					<li id="dict_detail_li" style="color:grey;cursor:default">字典明细</li>
				</ul>	
			</div><!-- .section -->
		 	<div class="bz_cont">
		 		<form id="dictForm">
		 		<input type="hidden" id="dict.temp_dict_code" name="dict.temp_dict_code"/>
				<input type="hidden" id="dict.dict_type" name="dict.dict_type"/>
		 	 	<table class="datadesr" style="width:400px;  margin-top:5px; margin-bottom:10px">
				<tr>
					<th style="width:100px; text-align:right" >字典编码：<span class="red">*</span></th>
					<td style="width:250px;">
					<input id="dict.dict_code" name="dict.dict_code" class="inp validate[required, maxSize[10],custom[onlyLetterNumber], ajax[ajaxDictCodeCall]]" />
					</td>
				</tr>
				<tr>
					<th style="width:100px; text-align:right">字典名称：<span class="red">*</span></th>
					<td style="width:250px;">
					<input id="dict.dict_name" name="dict.dict_name" class="inp validate[required, maxSize[100]]" />
					</td>
				</tr>
				<tr>
					<th style="width:100px; text-align:right">是否可配置：<span class="red">*</span></th>
					<td style="width:250px;">
					<input id="dict.is_manager_opr" name="dict.is_manager_opr" type="checkbox" />
					</td>
				</tr>
			</table><!-- .datadesr -->
			<input id="save_btn" type="submit" class="regbutton3" value="保存" style="margin-left:250px" />
			</form>
		 	</div><!-- .bz_cont -->
	</div>
	<!--初始化信息 end-->
</body>
</html>


